<template>
  <echartsView :loading="loading" :options="options"></echartsView>
</template>

<script>
import { echartsView } from '@/components'
import { getSigned } from '@/api/followUpManagement'
export default {
  components: {
    echartsView
  },
  props: {},
  data () {
    return {
      loading: false,
      options: {
        title: {
          text: '合同签约统计',
          x: 'center'
        },
        toolbox: {
          show: true
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        xAxis: {
          type: 'category',
          data: ['已签约', '未签约'],
          axisTick: {
            alignWithLabel: true
          }
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '签约统计',
            type: 'bar',
            data: []
          }
        ]
      }
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.fetchData()
    })
  },
  methods: {
    fetchData () {
      this.loading = true
      getSigned().then(res => {
        const { Allocated, Unallocated } = res
        this.options.series[0].data = [Allocated, Unallocated]
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>
<style scoped>
</style>
